home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / var / lib / dpkg / info / upower.postinst < prev    next >
Encoding:
Text File  |  2010-10-23  |  1.4 KB  |  48 lines

  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5. # Move a conffile without triggering a dpkg question
  6. mv_conffile() {
  7.     local OLDCONFFILE="$1"
  8.     local NEWCONFFILE="$2"
  9.  
  10.     [ -e "$OLDCONFFILE" ] || return 0
  11.  
  12.     echo "Preserving user changes to $NEWCONFFILE ..."
  13.     mv -f "$NEWCONFFILE" "$NEWCONFFILE".dpkg-new
  14.     mv -f "$OLDCONFFILE" "$NEWCONFFILE"
  15. }
  16.  
  17. get_pid() {
  18.     [ -n "$1" ] || return 0
  19.     [ -S /var/run/dbus/system_bus_socket ] || return 0
  20.  
  21.     dbus-send --system --dest=org.freedesktop.DBus --print-reply \
  22.               /org/freedesktop/DBus org.freedesktop.DBus.GetConnectionUnixProcessID \
  23.               string:$1 2>/dev/null | awk '/uint32/ {print $2}'
  24. }
  25.  
  26. if [ "$1" = "configure" ]; then
  27.     # migrate power history from DeviceKit-power
  28.     if dpkg --compare-versions "$2" lt-nl "0.9.1-1" && [ -d /var/lib/DeviceKit-power/ ]; then
  29.     if [ ! -d /var/lib/upower ] || rmdir /var/lib/upower 2>/dev/null; then
  30.         echo "Migrating old DeviceKit-power history.."
  31.         mv /var/lib/DeviceKit-power/ /var/lib/upower
  32.     fi
  33.     fi
  34.  
  35.     if dpkg --compare-versions "$2" lt "0.9.4-2"; then
  36.         mv_conffile "/etc/UPower.conf" "/etc/UPower/UPower.conf"
  37.     fi
  38.  
  39.     # restart upowerd if it was running before
  40.     pid=$(get_pid org.freedesktop.UPower)
  41.     if [ -n "$pid" ]; then
  42.         kill $pid 2>/dev/null || true
  43.         upower --version >/dev/null || true # will trigger through D-Bus activation
  44.     fi
  45. fi
  46.  
  47.  
  48.